package com.zhida.smartcontrol.pagectrl;

import com.alibaba.fastjson.JSON;
import com.yanzhenjie.kalle.Params;
import com.zhida.smartcontrol.common.Api;
import com.zhida.smartcontrol.knet.KalleCallBack;
import com.zhida.smartcontrol.mvp.BasePresenterImpl;

import java.util.List;

/**
 * author: tanjianpei
 * date: 2019/10/9 009 9:01
 * description:
 */
public class PageCtrlPresenter extends BasePresenterImpl<PageCtrlContract.View> implements PageCtrlContract.Presenter {

    @Override
    public void requestProjectList() {
        Params params = Params.newBuilder()
                .add("projectName", "")
                .build();
        mKalleCenter.get(Api.PROJECT_LIST, params, true, new KalleCallBack() {
            @Override
            public void onSuccess(String result, String msg) {
                List<ProjectListBean> projectList = JSON.parseArray(result, ProjectListBean.class);
                mView.showList(projectList);
            }

            @Override
            public void onFailed(String msg) {
                mView.showMsg(msg);
            }
        });
    }

}
